/****************************************************************************
**
** Copyright (c) 2013 - 2019 Jolla Ltd.
** Copyright (c) 2020 Open Mobile Platform LLC.
** Contact: Vesa-Matti Hartikainen <vesa-matti.hartikainen@jollamobile.com>
**
****************************************************************************/

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef DBUSADAPTOR_H
#define DBUSADAPTOR_H

#include <QDBusAbstractAdaptor>
#include "browserservice.h"

class DBusAdaptor : public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.sailfishos.browser")

public:
    DBusAdaptor(BrowserService *browserService);

public slots:
    // these two calls are kept in this service for compatibility
    // but any calls that require the UI to be shown should be added to
    // the UIServiceDBusAdaptor org.sailfishos.browser.ui service instead
    void openUrl(const QStringList &args);
    void activateNewTabView();

    void cancelTransfer(int transferId);
    void restartTransfer(int transferId);
    void dumpMemoryInfo(const QString &fileName);
private:
    BrowserService *m_BrowserService;
};

class UIServiceDBusAdaptor : public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.sailfishos.browser.ui")

public:
    UIServiceDBusAdaptor(BrowserUIService *browserService);

public slots:
    void openUrl(const QStringList &args);
    void openSettings();
    void activateNewTabView();

    void requestTab(int tabId, const QString &url);
    void closeTab(int tabId);

private:
    BrowserUIService *m_BrowserService;
};

#endif // DBUSADAPTOR_H
